(deftemplate Question
	(slot question)
	(slot response)
)
(deftemplate PCDiagnostic
(slot name)
)
(assert (Question (question nil)(response nil)))
(printout t  crlf "     >>> DIAGNOSTIC PC <<< " crlf "Please answer with Y or N ." crlf )



(deffunction get-salience (?name)
  (bind ?s (fetch (str-cat ?name "-salience")))
  (if (eq ?s nil) then
        (return 0)
   else
        (return ?s)))

(deffunction set-salience (?name, ?value)
  (store (str-cat ?name "-salience") ?value))

(set-salience-evaluation every-cycle)

(defrule q1
	(Question (question nil)(response nil))
	=>
	(printout t "Does disk seek? (Y/N)" crlf)
	(bind ?r (read))                                       ;;bind - citeste d la tastatura si punbe in variabila r
	(assert (Question (question "Does disk seek? (Y/N)")(response ?r)))
)

(defrule q2
	(Question (question "Does disk seek? (Y/N)")(response Y))
	=>
	(printout t "Does booting begin? (Y/N)" crlf)
	(bind ?r (read))                                       ;;bind - citeste d la tastatura si punbe in variabila r
	(assert (Question (question "Does booting begin? (Y/N)")(response ?r)))
)


(defrule q3
	(Question (question "Does booting begin? (Y/N)")(response Y))
	=>
	(printout t "->> END" crlf)
)
(defrule q4
	(Question (question "Does booting begin? (Y/N)")(response N))
	=>
	(printout t "->> Check keyboard, RAM, power supply" crlf)
)

(defrule q5
	(Question (question "Does disk seek? (Y/N)")(response N))
	=>
	(printout t "Does computer beep? (Y/N)" crlf)
	(bind ?r (read))                                       ;;bind - citeste d la tastatura si punbe in variabila r
	(assert (Question (question "Does computer beep? (Y/N)")(response ?r)))
)

(defrule q6
	(Question (question "Does computer beep? (Y/N)")(response N))
	=>
	(printout t "->> ERROR" crlf)
)

(defrule q7
	(Question (question "Does computer beep? (Y/N)")(response Y))
	=>
	(printout t "How many beeps? (< 3) (Y/N)" crlf)
	(bind ?r (read))                                       ;;bind - citeste d la tastatura si punbe in variabila r
	(assert (Question (question "How many beeps? (< 3) (Y/N)")(response ?r)))
)

(defrule q8
    (declare (salience 2))
	(Question (question "How many beeps? (< 3) (Y/N)")(response Y))
	=>
	(printout t "->> check loose RAM" crlf)
)


(defrule q9
    (declare (salience 1))
	(Question (question "How many beeps? (< 3) (Y/N)")(response N))
	=>
	(printout t "->> check keyboard and motherboard" crlf)
)

(run)
(facts)